package com.alibaba.dubbo.common.header;

import java.util.Map;

import com.alibaba.dubbo.common.HeaderProvider2;

public class HeaderProvider2Wrapper implements HeaderProvider2 {
	
	private HeaderProvider2 provider;
	public HeaderProvider2Wrapper(HeaderProvider2 provider){
		this.provider = provider;
	}

	@Override
	public Map<String, String> getHeaders() {
		if(provider == null) return null;
		return provider.getHeaders();
	}


	@Override
	public String getHeader(String key) {
		if(provider == null) return null;
		return provider.getHeader(key);
	}

	@Override
	public String getHeader(String key, String defaultValue) {
		if(provider == null) return null;
		return provider.getHeader(key, defaultValue);
	}

	@Override
	public String removeHeader(String key) {
		if(provider != null){
			return provider.removeHeader(key);
		}
		return null;
	}

	@Override
	public void removeHeaders() {
		if(this.provider != null){
			this.provider.removeHeaders();
		}
	}

	@Override
	public void setHeaders(Map<String, String> values) {
		if(this.provider != null){
			this.provider.setHeaders(values);
		}
	}

	@Override
	public void setHeader(String key, String value) {
		if(this.provider != null){
			this.provider.setHeader(key, value);
		}
	}

	@Override
	public boolean containsHeader(String key) {
		if(this.provider == null) return false;
		return this.provider.containsHeader(key);
	}
}
